ihelpuoo.weboo.runtime.ActionDetailHTML = function()
{
	this.shell = document.createElement("DIV");
	this.title = document.createElement("H1");
	this.shell.appendChild(this.title);
	
	this.ancestores = ihelpuoo.dom.createSimpleElement("DIV","action_ancestores");
	this.shell.appendChild(this.ancestores);

	this.actionName = ihelpuoo.dom.createSimpleElement("DIV","abstract_action_name");
	this.typeName = document.createElement("SPAN");
	this.icon = ihelpuoo.dom.createSimpleElement("IMG","icon16");
	this.actionName.appendChild(this.icon);
	this.actionName.appendChild(this.typeName);
	this.shell.appendChild(this.actionName);
	
	this.comment = ihelpuoo.dom.createSimpleElement("PRE","module_comment");
	this.shell.appendChild(this.comment);

	this.shell.appendChild(ihelpuoo.dom.createSimpleElement("H2",null,"Params"));
	this.paramsTable = document.createElement("TABLE");
	var tr = ihelpuoo.dom.insertRow(this.paramsTable);
	ihelpuoo.dom.insertCell(tr,"module_attname","Name");
	ihelpuoo.dom.insertCell(tr,"module_attname","Type");
	ihelpuoo.dom.insertCell(tr,"module_attname","comment");
	ihelpuoo.dom.insertCell(tr,"module_attname","CheckerSetting");
	this.shell.appendChild(this.paramsTable);
	this.btn = document.createElement("<INPUT>");
	this.btn.type = "button";
	this.btn.value = "G-getPostString()";
	ihelpuoo.event.add(this.btn,"click",ihelpuoo.weboo.runtime.generateViewPostFunction);
	this.shell.appendChild(this.btn);
	
	this.shell.appendChild(ihelpuoo.dom.createSimpleElement("H2",null,"Properties"));
	this.propertiesTable = document.createElement("TABLE");
	tr = ihelpuoo.dom.insertRow(this.propertiesTable);
	ihelpuoo.dom.insertCell(tr,"module_attname","Name");
	ihelpuoo.dom.insertCell(tr,"module_attname","Value");
	this.shell.appendChild(this.propertiesTable);
}

ihelpuoo.weboo.runtime.generateViewPostFunction = function()
{
	var ele = ihelpuoo.event.srcElement(this);
	var rt = ihelpuoo.weboo.runtime.me();
	var m = rt.getModule(ele.getAttribute("module"));
	var a = m.getAction(ele.getAttribute("action"));
	var sb = ">> " + m.name + "." + a.name;
	sb += "\r\n\r\ngetPostString: function()\r\n{";
	if(null!=a.detail.params)
	{
		for(var i=0; i<a.detail.params.length; i++)
		{
			var p = a.detail.params[i];
			var fn = null;
			if("digital"==p.type)
				fn = "getInt";
			else
				fn = "getString";
			if(i==0)
			{
				sb += "\r\n\tvar re = \""+p.name+"=\"+this.view."+fn+"(\"" + p.name + "\");";
			}
			else
			{
				sb += "\r\n\tre += \"&"+p.name+"=\"+this.view."+fn+"(\"" + p.name + "\");";
			}
		}
		sb += "\r\n\treturn re;";
	}
	sb += "\r\n}";
	document.DA.codePanel.value = sb;
	document.DA.style.display="block";
	document.DA.style.top = ihelpuoo.widget.GC.getTop(ele) - document.DA.offsetHeight;
	document.DA.style.left = ihelpuoo.widget.GC.getLeft(ele);
}

ihelpuoo.weboo.runtime.ActionDetailHTML.prototype
=
{
	hide: function()
	{
		this.shell.style.display = "none";
	}
	
	,
	show: function()
	{
		this.shell.style.display = "block";
	}
	
	,
	setAction: function(a)
	{
		this.btn.setAttribute("module",a.module.name);
		this.btn.setAttribute("action",a.name);
	}
	
	,
	setTitle: function(s)
	{
		this.title.innerHTML = "Action: " + s;
	}
	
	,
	setAncestores: function(ancestores)
	{
		if(null==ancestores || ancestores.lenght==0)
		{
			this.ancestores.style.display = "none";
			return;
		}
		this.ancestores.style.display = "block";
		this.ancestores.innerHTML = "";
		this._addAncestor(this.ancestores,ancestores,0);
	}
	
	,
	_addAncestor: function(ele,ancestores,index)
	{
		if(index==ancestores.length)return;
		var div = ihelpuoo.dom.createSimpleElement("DIV","tree_node");
		var action = ancestores[index];
		if(null==action.HTML)
			action.HTML.render();
		var a = ihelpuoo.dom.createSimpleElement("A",null,action.fullName());
		a.href="javascript:void(0)";
		div.appendChild(a);
		ele.appendChild(div);
		this._addAncestor(div,ancestores,index+1);
	}
	
	,
	setComment: function(s)
	{
		this.comment.innerHTML = s;
	}
	
	,
	addParam: function(p)
	{
		var tr = ihelpuoo.dom.insertRow(this.paramsTable);
		if(p.isRequired)
			tr.style.fontWeight = "bold";
		ihelpuoo.dom.insertCell(tr,"module_attvalue",(p.isRequired?"*":"") + p.name);
		var td = ihelpuoo.dom.insertCell(tr,"module_attvalue",p.type);
		td.setAttribute("title",p.checkerName);
		ihelpuoo.dom.insertCell(tr,"module_attvalue",p.comment);
		td = ihelpuoo.dom.insertCell(tr,"module_attvalue",p.checkerSetting);
		td.setAttribute("title",p.checkerName);
	}
	
	,
	addProperty: function(p)
	{
		var tr = ihelpuoo.dom.insertRow(this.propertiesTable);
		ihelpuoo.dom.insertCell(tr,"module_attvalue",p.name);
		ihelpuoo.dom.insertCell(tr,"module_attvalue",p.value);
	}
	
	,
	setType: function(isAbstract,typeName)
	{
		this.typeName.innerHTML = typeName;
		if(isAbstract)
		{
			this.icon.src = ihelpuoo.http.server().icon("006.gif");
			this.actionName.className = "abstract_action_name";
		}
		else
		{
			this.icon.src = ihelpuoo.http.server().icon("005.gif");
			this.actionName.className = "action_name";
		}
	}

}